package com.dkts.oil.web.vo.request;

import com.dkts.oil.router.TransportRoute;
import com.dkts.oil.model.GHPoint;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.List;


@Slf4j
@Data
@Schema(description = "路由规划公共请求参数")
public class RouteCommonRequest {
    @Schema(description = "   YK_TO_ZY(\"YK_TO_ZY\", \"yk到zy站运输路线规划\"),    完成 \r\n \n" +
            "    ZY_TO_CBK(\"ZY_TO_CBK\", \"zy站到cbk运输路线规划\"),  完成 \r\n \n" +
            "    CBK_TO_XHK(\"CBK_TO_XHK\", \"cbk到xhk运输路线规划\"), 完成\r\n \n" +
            "    XHK_TO_WCGYZX(\"XHK_TO_WCGYZX\", \"xhk到wcgyzx运输路线规划\"), 完成\r\n \n" +
            "    LYC_TO_ZY(\"LYC_TO_ZY\", \"lyc到zy站运输路线规划\"),  完成 \r\n \n" +
            "    YLCC(\"YLCC\", \"ylcc运输规划\"), 不做，就是把整个串起来，业务端整合就行 \r\n \n" +
//            "    KQ_ROUTE(\"KQ_ROUTE\", \"kq路由规划\"), \r\n \n" +
            "    KQ_LAYOUT(\"KQ_LAYOUT\", \"kq内部布局与路由规划\") " +
            "",example = "YK_TO_ZY")
    private String routeModel;

    @Schema(description = "点信息",
            example = "[{\"lat\": 27.58765, \"lon\": 116.497503}, {\"lat\": 27.638004, \"lon\": 116.747283}]")
    private List<GHPoint> points;

    @Schema(description = "从启点到最佳点，超过该距离，创建起点到最佳点的新的道路，单位米 默认：0米",example = "0")
    private Double createNewRoadDistance;


    @Schema(description  = "（机场边界json）" +
            " \n  CBK到XHK XHK到WCGY时有效",example = "{ \"type\": \"Feature\", \"properties\": { \"id\": 3, \"name\": \"杭州萧山国际机场\" }, \"geometry\": { \"type\": \"MultiPolygon\", \"coordinates\": [ [ [ [ 120.401862649356715451, 30.237778607536796471 ], [ 120.446583467371425513, 30.255615234375031974 ], [ 120.456406537224367526, 30.253030215992676943 ], [ 120.4549201516545196, 30.246179917279444993 ], [ 120.445484834558925513, 30.247343175551502981 ], [ 120.4494269875920196, 30.242948644301502981 ], [ 120.459767061121425513, 30.240686753216944993 ], [ 120.454273897058925513, 30.235128963694887005 ], [ 120.406095616957813377, 30.214804256663640558 ], [ 120.39750043083648734, 30.236130658318053577 ], [ 120.401862649356715451, 30.237778607536796471 ] ] ] ] } }")
    public String  pointGeoJson;

    @Schema(description = "机场大门位置 \n" +
            "\r\n \nCBK到XHK XHK到WCGY时有效",example = "{\"lat\": 27.58765, \"lon\": 116.497503}")
    public GHPoint airportDoorPoint;

    @Schema(description = "从启点到最佳点，超过该距离，创建起点到最佳点的新的道路后，\r\n\n " +
            " \n 超过多少米，绕过障碍物进行路线规划，单位米 默认：100mi",example = "100")
    public Double localRouteDistance;


    public void check() {
        if (routeModel == null || routeModel.isEmpty()) {
            log.error("路由类型不能为空");
            throw new RuntimeException("路由类型不能为空");
        }
        TransportRoute.fromKey(routeModel);

        if (points == null || points.isEmpty()) {
            log.error("起点和终点不能为空");
            throw new RuntimeException("起点和终点不能为空");
        }
        for (GHPoint point : points) {
            if (!point.isValid()) {
                log.error("点坐标无效");
                throw new RuntimeException("点坐标无效");
            }
        }
        if (this.createNewRoadDistance == null){
            this.createNewRoadDistance = 0D;
        }
        if (this.localRouteDistance== null || this.localRouteDistance <=0){
            this.localRouteDistance = 100D;
        }
    }

}
